<template>
  <ul class="tab-bar">
    <li
      is="router-link"
      tag="li"
      v-for="nav in navs"
      :key="nav.path"
      :to="nav.path"
      :replace="nav.replace"
    >
      <i class="iconfont" v-html="nav.icon"></i>
      <span>{{ nav.title }}</span>
    </li>
  </ul>
</template>

<script>
import routes from '@/router/routes'
export default {
  name: 'TabBar',
  computed: {
    navs() {
      return routes
        .filter((route) => route.meta.inTabBar)
        .map(({ path, meta: { title, icon, replace } }) => ({
          path,
          title,
          icon,
          replace,
        }))
    },
  },
}
</script>

<style lang="less" scoped>
@font-face {
  font-family: 'iconfont';
  src: url('//at.alicdn.com/t/font_2728644_buq0di4i3yj.woff2?t=1635251535375')
      format('woff2'),
    url('//at.alicdn.com/t/font_2728644_buq0di4i3yj.woff?t=1635251535375')
      format('woff'),
    url('//at.alicdn.com/t/font_2728644_buq0di4i3yj.ttf?t=1635251535375')
      format('truetype');
}

.iconfont {
  font-family: 'iconfont' !important;
  font-size: 24px;
  font-style: normal;
  -webkit-font-smoothing: antialiased;
  -webkit-text-stroke-width: 0.2px;
  -moz-osx-font-smoothing: grayscale;
}

.tab-bar {
  color: #666;
  display: flex;
  height: 96px;
  font-size: 12px;
  border-top: 1px solid #ccc;

  li {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: space-around;
  }
}

.router-link-exact-active,
.router-link-active {
  color: #d81e06;
}
</style>
